﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Adams.Web.Areas.MyAdams.Controllers
{
    [Authorize]
    [EnsureSsl]
    public class ProfileController : Controller
    {
        [AppendLayoutModel]
        public ActionResult Index()
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.Index.PageLoad(memberId);
            return View(Adams.Web.Controllers.MobileCheck.IsMobile() ? "Index.Mobile" : "Index", model);
        }

        [AppendLayoutModel]
        public ActionResult Email()
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.Email.PageLoad(memberId);
            return View(Adams.Web.Controllers.MobileCheck.IsMobile() ? "Email.Mobile" : "Email", model);
        }

        public JsonResult SaveEmail(Adams.Web.Areas.MyAdams.Models.Profile.Email.FormInput input)
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.Email.SaveEmail(memberId, input);
            return Json(model);
        }

        [AppendLayoutModel]
        public ActionResult Password()
        {

            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.Password.PageLoad(memberId);
            return View(Adams.Web.Controllers.MobileCheck.IsMobile() ? "Password.Mobile" : "Password", model);
        }

        public JsonResult SavePassword(Adams.Web.Areas.MyAdams.Models.Profile.Password.FormInput input)
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.Password.SavePassword(memberId, input);
            return Json(model);
        }

        [AppendLayoutModel]
        public ActionResult General()
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.General.PageLoad(memberId);
            return View(Adams.Web.Controllers.MobileCheck.IsMobile() ? "General.Mobile" : "General", model);
        }

        public JsonResult SaveGeneral(Adams.Web.Areas.MyAdams.Models.Profile.General.FormInput input)
        {
            var memberId = User.Identity.Name.ToInt();
            var model = Adams.Web.Areas.MyAdams.Logic.Profile.General.SaveGeneral(memberId, input);
            return Json(model);
        }

        //[AppendLayoutModel]
        //public ActionResult CreditCard()
        //{
        //    string token = User.Identity.Name;
        //    var model = Adams.Web.Areas.MyAdams.Logic.Profile.CreditCard.PageLoad(token);
        //    model.ReturnTo = Request["r"];
        //    return View(model);
        //}

       
        //public JsonResult SaveCreditCard(Adams.Web.Models.Profile.SaveCreditCardInput input)
        //{
        //    string token = User.Identity.Name;
        //    var model = Adams.Web.Areas.MyAdams.Logic.Profile.CreditCard.SaveCreditCard(token, input);
        //    return Json(model);
        //}
    }
}
